package com.thinvent.remotepassword.util;

public class UserContext {

    private static ThreadLocal<String> threadLocal = new ThreadLocal<>();

    /**
     * 设置用户id
     * @param id
     */
    public static void put(String id) {
        threadLocal.set(id);
    }

    /**
     * 获取用户id
     * @return
     */
    public static String get() {
        return threadLocal.get();
    }

    /**
     * 移除用户id 防止内存泄漏
     */
    public static void remove() {
        threadLocal.remove();
    }

}
